package com.jams.goodox.activity.home;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.jams.goodox.BaseActivity;
import com.jams.goodox.R;
import com.jams.goodox.adapter.CustomFragmentPagerAdapter;
import com.jams.goodox.utils.StyleUtil;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;

/**
 * Created by Administrator on 2017/10/1.
 */

public class OrderListActivity extends BaseActivity{

    @Bind(R.id.tab_layout)
    TabLayout tabLayout;
    @Bind(R.id.viewPager)
    ViewPager viewPager;

    private List<Fragment> fragmentList;
    private List<String> tabsTitle;

    private int position;
    @Override
    protected int getLayoutId() {
        return R.layout.order_list_activity;
    }

    @Override
    protected void init() {
        StyleUtil.titleBackKey(this, "我的订单");

        position=getIntent().getIntExtra("position",0);

        fragmentList=new ArrayList<>();
        tabsTitle=new ArrayList<>();
        OrderFragment fragment1= OrderFragment.getInstance("1");
        OrderFragment fragment2= OrderFragment.getInstance("2");
        OrderFragment fragment3= OrderFragment.getInstance("3");
        OrderFragment fragment4= OrderFragment.getInstance("4");
        OrderFragment fragment5= OrderFragment.getInstance("5");
        fragmentList.add(fragment1);
        tabsTitle.add("待付款");
        fragmentList.add(fragment2);
        tabsTitle.add("待发货");
        fragmentList.add(fragment3);
        tabsTitle.add("待确认");
        fragmentList.add(fragment4);
        tabsTitle.add("待评价");
        fragmentList.add(fragment5);
        tabsTitle.add("已完成");

        viewPager.setAdapter(new CustomFragmentPagerAdapter(getSupportFragmentManager(), tabsTitle, fragmentList));

        tabLayout.setupWithViewPager(viewPager);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

        viewPager.setOffscreenPageLimit(4);
        viewPager.setCurrentItem(position);
    }
}
